/********************************
功  能：独立按键之基于底层程序模块的应用程序开发
编程人：ZZT
版  本：V1.0
时  间：2023/12/21
**********************************/
#include <reg51.h>
#include "Key.h"
#include "display.h"

void Key_Service();
void Dis_Service();

unsigned int NumCnt;

void main()
{
	LEDBuff[4] = 23;
	LEDBuff[5] = 23;
	LEDBuff[6] = 23;
	LEDBuff[7] = 23;
	while(1)
	{
		Dis_Service();
		Key_Service();
		Display();
	}
}

void Dis_Service()
{
	LEDBuff[0] = NumCnt / 1000;
	LEDBuff[1] = NumCnt / 100 % 10;
	LEDBuff[2] = NumCnt / 10 % 10;
	LEDBuff[3] = NumCnt % 10;
}

void Key_Service()
{
	switch(Key_Scan())
		{
			case 0:break;
			case 1:NumCnt++;if (NumCnt > 9999) NumCnt = 0;break;
			case 2:NumCnt--;if (NumCnt > 9999) NumCnt = 9999;break;
			case 3:NumCnt = 0;break;
			case 4:NumCnt = 88;break;
			default:break;
		}
}